﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace FlowPipe
{
    public partial class FlowControl : UserControl
    {
        public FlowControl()
        {
            InitializeComponent();
            Timer myTimer = new Timer();
            myTimer.Interval = 500;
            myTimer.Tick += myTimer_Tick;
            myTimer.Enabled = true;
        }

        private void myTimer_Tick(object sender, EventArgs e)
        {
            this.Invalidate();
        }

        private Graphics g;
        private int width;
        private int height;

        private bool isActive;
        public bool IsActive
        {
            get { return isActive; }
            set
            {
                isActive = value;                
            }
        }

        private Color runColor = Color.FromArgb(128, 128, 255);
        public Color RunColor
        {
            get { return runColor; }
            set
            {
                runColor = value;                
            }
        }

        private Color startColor = Color.FromArgb(73, 73, 73);
        public Color StartColor
        {
            get { return startColor; }
            set
            {
                startColor = value;                
            }
        }

        private Color endColor = Color.FromArgb(247, 247, 247);
        public Color EndColor
        {
            get { return endColor; }
            set
            {
                endColor = value;
            }
        }

        private int length = 10;
        public int Length
        {
            get { return length; }
            set
            {
                length = value;
            }
        }

        private double extent = 0.75;
        public double Extent
        {
            get { return extent; }
            set
            {
                extent = value;
            }
        }

        private int sapce = 5;
        public int Space
        {
            get { return sapce; }
            set
            {
                sapce = value;
            }
        }

        private int speed = 5;
        public int Speed
        {
            get { return speed; }
            set
            {
                speed = value;
            }
        }
        //定义水平流动还是垂直流动
        private bool isVertical = false;
        public bool IsVertical
        {
            get { return isVertical; }
            set
            {
                isVertical = value;
            }
        }
        //流动状态1从左到右,2从上到下,3从右到左,4从下到上
        private int flowNum = 1;
        public int FlowNum
        {
            get { return flowNum; }
            set
            {
                flowNum = value;
            }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            g = e.Graphics;
            g.SmoothingMode=SmoothingMode.AntiAlias;
            g.SmoothingMode = SmoothingMode.HighQuality;
            width = this.Width;
            height = this.Height;
            //绘制渐变色的外框
            LinearGradientBrush brush;
            Rectangle rect = new Rectangle(0, 0, width, height/2);
            brush = new LinearGradientBrush(rect, startColor, endColor, LinearGradientMode.Vertical);
            g.FillRectangle(brush, rect);
            

        }
    }
}
